package com.yidu.hbatsams.action.TrainingPlan.zxr;

import com.yidu.hbatsams.domain.AtsPlanCurriculum;
import com.yidu.hbatsams.service.TrainingPlan.zxr.AtsCurriculumService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 朱星润
 * @类的描述——课计划Controller
 * @date 2019/10/30下午 02:29
 */
@Controller
@RequestMapping("atsCurriculumController")
public class AtsCurriculumController {
    @Resource
    AtsCurriculumService atsCurriculumService;//课计划Service


    @RequestMapping("curPie")
    @ResponseBody
    public List<AtsPlanCurriculum> curPie(HttpServletRequest request, String ids, Map<String, Object> map) {
        String[] id = ids.split(",");
        map.put("ids", id);
        List<AtsPlanCurriculum> list = atsCurriculumService.curPie(request, map);
        return list;

    }

    /**
     *课计划统计图
     * @param request
     * @param ids
     * @param map
     * @return
     */
    @RequestMapping("curEchar")
    @ResponseBody
    public List<AtsPlanCurriculum> echar(HttpServletRequest request, String ids, Map<String, Object> map) {
        String[] id = ids.split(",");//id集合
        map.put("ids", id);//传入map
        List<AtsPlanCurriculum> list = atsCurriculumService.curEchar(request, map);
        return list;

    }

    /**
     * id查询
     * @param curriculumId
     * @return
     */
    @RequestMapping("findById")
    @ResponseBody
    public Map<String, Object> findById(Integer curriculumId) {
        AtsPlanCurriculum atsPlanCurriculum = atsCurriculumService.findById(curriculumId);
        Map<String, Object> map = new HashMap<>();
        map.put("data", atsPlanCurriculum);
        return map;
    }

    /**
     * 统计图复选框
     * @param request
     * @param atsCurriculum
     * @return
     */
    @RequestMapping("comboBox")
    @ResponseBody
    public List<AtsPlanCurriculum> comboBox(HttpServletRequest request, AtsPlanCurriculum atsCurriculum) {
        return atsCurriculumService.comboBox(request, atsCurriculum);
    }

    /**
     * 查所有
     * @param request
     * @param atsCurriculum
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("selectAll")
    @ResponseBody
    public Map<String, Object> selectAll(HttpServletRequest request, AtsPlanCurriculum atsCurriculum, @RequestParam(required = false, defaultValue = "1", value = "page") Integer pageNum, @RequestParam(required = false, defaultValue = "10", value = "limit") Integer pageSize) {
        List<AtsPlanCurriculum> list = atsCurriculumService.findAll(request, atsCurriculum, pageNum, pageSize);
        int count = atsCurriculumService.count(request, atsCurriculum);
        Map<String, Object> map = new HashMap<>();
        map.put("data", list);//查所有
        map.put("count", count);//查总行数
        map.put("code", 0);
        map.put("msg", "");//消息

        return map;
    }
}
